// =============================================================
// CTask class
// ---------------------------------------
// Author : Woo-Hyun Kim
// Email : woorung@icu.ac.kr or woorung@nhncorp.com
// Date : Jul. 25, 2006
// =============================================================
#ifndef CTaskH
#define CTaskH
//-----------------------------------------------------------------
#include <iostream>
#include <iterator>
#include <vector>
#include <list>
#include <algorithm>
#include <fstream>
#include <string>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

#include "CProcess.h"
#include "CAction.h"

using namespace std;
//---------------------------------------------------------------
class CTask : public CProcess {
private :
	string name;
	int current_pos;

	map<string,string> common_task_variables;
	map<string,string> task_variables;
	vector<CAction> actions;

protected:
	int read_upstream(const void *buf, size_t size);
	int read_downstream(const void *buf, size_t size);
	void before_run();

public :
	CTask(string &name);
	~CTask();

	void run(); // overridden function from CProcess

	int registerCommonTaskVariables(map<string,string> &variables);
	int registerTaskVariables(map<string,string> &variables);
	int registerAction(CAction &action);

	string &getName();
	string &getParameter(char *cattr);
	string &getParameter(string &attr);
	int hasMoreActions();
	CAction &getNextAction();
};
//----------------------------------------------------------------
#endif
